DICOMSeriesToVolumeOperator Slice Removal Fix #527
Merged
+9
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I discovered that the
DICOMSeriesToVolumeOperator
does not correctly handle slice removal within theprepare_series
method.I tested with an axial MRI series that has a single, non-image DICOM file (
ImageOrientationPatient
andImagePositionPatient
tags are absent). This method is built to handle cases like this and remove the slice prior to volume conversion; however, I discovered the removal process is incorrect. Below is a terminal output when testing the current operator (I added in a few logs for debugging):Slice removal is occurring (total # of slices drops by 1), but the wrong slice is being removed; thus, the non-image DICOM file is still present and causes the error. The current removal functionality (below) iterates over indices of
slice_indices_to_be_removed
, not the actual slice indices stored in the list (i.e. the actual slice indices ofseries._sop_instances
). This explains why slice 0 is being removed (1 element in list = 0th index).My fix is to iterate over a sorted
slice_indices_to_be_removed
in reverse order and pull out the slice index to delete; sorting in reverse order will allow us to remove slices without having to worry about reindexing. Below is the terminal output with the fixes implemented (slice index to remove = removed slice index):I think we should make the slice removal confirmation an
info
log so that users have some feedback that this removal occurred. Take it or leave it on thedebug
logs (would be fine removing the total slice # logs all together), will defer to your guidance here.